<template>
    <view class="container">
        <view class="qrcode">
            <image mode="widthFix" :src="qrcode" @tap.stop.prevent="previewImage"></image>
        </view>
    </view>
</template>

<script>
const app = getApp();
export default {
    data() {
        return {
            qrcode: ''
        };
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function (options) {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        // 获取推广二维码
        this.getPoster();
    },
    methods: {
        /**
         * 获取推广二维码
         */
        getPoster: function () {
            let that = this;
            uni.showLoading({
                title: '加载中'
            });
            app.globalData._get(
                'qrcode/poster',
                {},
                function (result) {
                    // 设置当前页面标题
                    uni.setNavigationBarTitle({
                        title: result.data.words.qrcode.title.value
                    });
                    that.setData(result.data);
                },
                null,
                function () {
                    uni.hideLoading();
                }
            );
        },

        previewImage: function () {
            uni.previewImage({
                current: this.qrcode,
                urls: [this.qrcode]
            });
        }
    }
};
</script>
<style>
@import './qrcode.css';
</style>
